<?php

class Model_kata extends CI_Model {

	public function __construct()
    {
        $this->load->database();
    }
	
	public function get_filter($search_string=null)
    {
	    
		$this->db->select('*');
		$this->db->from('filter');

		if($search_string){
			$this->db->like('kata', $search_string);
		}
		$this->db->group_by('id');
		$this->db->order_by('id', 'Asc');
		$query = $this->db->get();
		return $query->result_array(); 	
    }
	
	public function get_sinonim($search_string=null)
    {
	    
		$this->db->select('*');
		$this->db->from('sinonim');

		if($search_string){
			$this->db->like('kata', $search_string);
		}
		$this->db->group_by('id');
		$this->db->order_by('id', 'Asc');
		$query = $this->db->get();
		return $query->result_array(); 	
    }
	
	function simpan_filter($data)
    {
		$insert = $this->db->insert('filter', $data);
	    return $insert;
	}
	
	function simpan_simbol($data)
    {
		$insert = $this->db->insert('simbol', $data);
	    return $insert;
	}
	
	function simpan_sinonim($data)
    {
		$insert = $this->db->insert('sinonim', $data);
	    return $insert;
	}
	
	function ubah_filter($id, $data)
    {
		$this->db->where('id', $id);
		$this->db->update('filter', $data);
		$report = array();
		$report['error'] = $this->db->_error_number();
		$report['message'] = $this->db->_error_message();
		if($report !== 0){
			return true;
		}else{
			return false;
		}
	}
	
	function ubah_simbol($id, $data)
    {
		$this->db->where('id', $id);
		$this->db->update('simbol', $data);
		$report = array();
		$report['error'] = $this->db->_error_number();
		$report['message'] = $this->db->_error_message();
		if($report !== 0){
			return true;
		}else{
			return false;
		}
	}
	
	function ubah_sinonim($id, $data)
    {
		$this->db->where('id', $id);
		$this->db->update('sinonim', $data);
		$report = array();
		$report['error'] = $this->db->_error_number();
		$report['message'] = $this->db->_error_message();
		if($report !== 0){
			return true;
		}else{
			return false;
		}
	}
	
	function delete_filter($id){
		$this->db->where('id', $id);
		$this->db->delete('filter'); 
	}
	
	function delete_simbol($id){
		$this->db->where('id', $id);
		$this->db->delete('simbol'); 
	}
	
	function delete_sinonim($id){
		$this->db->where('id', $id);
		$this->db->delete('sinonim'); 
	}

}